<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <base href="<%=basePath%>">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <%@ include file="../common/baseCss.jsp" %>
    <title>站点个性化信息</title>
</head>
<body>

<div class="page-container">
    <div class="button-group">
        <a href="javascript:;" onclick="layer_show('添加信息','siteInfoAddPage?siteId=${siteId}','','')" class="btn btn-primary radius">
            <i class="iconfont marginRight6">&#xe600;</i>添加信息
        </a>
        <a class="btn btn-success radius r" href="javascript:location.replace(location.href);" title="刷新">
            <i class="iconfont">&#xe618;</i>
        </a>
    </div>
    <table class="table table-border table-bordered table-hover table-bg mytable">
        <thead>
        <tr class="text-c tableTH">
            <th width="100">ID</th>
            <th width="100">数据名</th>
            <th width="100">数据key</th>
            <th width="170">数据值</th>
            <th width="30">操作</th>
        </tr>
        </thead>
        <tbody class='tableTR'>
        <c:forEach items="${infos}" var="info">
            <tr>
                <td>${info.id}</td>
                <td>${info.dataName}</td>
                <td>${info.dataKey}</td>
                <td>${info.dataValue}</td>
                <td>
                    <a title='编辑' href='javascript:;' onclick='layer_show("修改信息","siteInfoEditPage?infoId=${info.id}&siteId=${siteId}" ,"","")' style='text-decoration:none'><i class='iconfont marginLeft12'>&#xe60a;</i></a>
                    <a title='删除' href='javascript:;' onclick='info_del(this, "${info.id}")' class='ml-5' style='text-decoration:none'><i class='iconfont marginLeft12'>&#xe612;</i></a>
                </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
</div>

<%@ include file="../common/baseJs.jsp" %>
<script type="text/javascript" src="manager/js/plugin/jquery.dataTables.min.js"></script>
<script type="text/javascript">
    var rootPath = getRootPath();
    function info_del(data, id) {
        layer.confirm('删除须谨慎，确认要删除吗？',function(index){
            $.ajax({
                url: rootPath + '/delSiteInfo',
                type: 'POST',
                data: {
                    'infoId': id
                },
                success: function (data) {
                    layer.msg('成功', {icon: 1, time: 1000}, function () {
                        window.location.href = rootPath + '/siteInfoPage?siteId=${siteId}';
                    });
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    layer.alert("error:(");
                }
            });
        });
    }
</script>

</body>
</html>